#include "stdafx.h"

#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"

#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#include "OptionSet.h"
#include "SparseState.h"


#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif


static void ObjectC_property(StyleContext &sc,int activitySet);


void ObjectCProcess( StyleContext &sc ,const char* s,int activitySet)
{
	sc.SetState(SCE_C_DEFAULT|activitySet);
	switch( s[1] )
	{
	case 'p':
		if( strcmp(s,"@property" ) == 0 )
			ObjectC_property( sc,activitySet);
	break;

	}

}

static const CharacterSet setWordStart(CharacterSet::setAlpha, "_@", 0x80, true);
static const CharacterSet setWord(CharacterSet::setAlphaNum, "._@", 0x80, true);

static void ObjectC_property(StyleContext &sc,int activitySet)
{
	bool bProperty = false;
	for (; sc.More(); sc.Forward()) {
		
		if( ';' == sc.ch || '\r' == sc.ch || '\n' == sc.ch )
		{
			return;
		}

		if( '(' == sc.ch ){
			sc.SetState(SCE_C_OPERATOR|activitySet);
			bProperty = true;
			continue;
		}

		if( bProperty )
		{
			if( setWordStart.Contains( sc.ch ) )
			{
				sc.SetState( SCE_C_WORD | activitySet );
				for (; sc.More(); sc.Forward()) 
				{
					if( !setWord.Contains( sc.ch ) )
					{
						sc.SetState(SCE_C_OPERATOR|activitySet);
						break;
					}
				}
			}
			else
			{
				sc.SetState(SCE_C_OPERATOR|activitySet);
			}
		}

		if( ')' == sc.ch){
			return;
		}
	}
}